package com.ruoyi.project.yf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.yf.domain.YfStockDayLine;
import com.ruoyi.project.yf.service.IYfStockDayLineService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 股票日均线Controller
 * 
 * @author 云峰
 * @date 2020-06-15
 */
@RestController
@RequestMapping("/yf/line")
public class YfStockDayLineController extends BaseController
{
    @Autowired
    private IYfStockDayLineService yfStockDayLineService;

    /**
     * 查询股票日均线列表
     */
    @PreAuthorize("@ss.hasPermi('yf:line:list')")
    @GetMapping("/list")
    public TableDataInfo list(YfStockDayLine yfStockDayLine)
    {
        startPage();
        List<YfStockDayLine> list = yfStockDayLineService.selectYfStockDayLineList(yfStockDayLine);
        return getDataTable(list);
    }

    /**
     * 导出股票日均线列表
     */
    @PreAuthorize("@ss.hasPermi('yf:line:export')")
    @Log(title = "股票日均线", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(YfStockDayLine yfStockDayLine)
    {
        List<YfStockDayLine> list = yfStockDayLineService.selectYfStockDayLineList(yfStockDayLine);
        ExcelUtil<YfStockDayLine> util = new ExcelUtil<YfStockDayLine>(YfStockDayLine.class);
        return util.exportExcel(list, "line");
    }

    /**
     * 获取股票日均线详细信息
     */
    @PreAuthorize("@ss.hasPermi('yf:line:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yfStockDayLineService.selectYfStockDayLineById(id));
    }

    /**
     * 新增股票日均线
     */
    @PreAuthorize("@ss.hasPermi('yf:line:add')")
    @Log(title = "股票日均线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YfStockDayLine yfStockDayLine)
    {
        return toAjax(yfStockDayLineService.insertYfStockDayLine(yfStockDayLine));
    }

    /**
     * 修改股票日均线
     */
    @PreAuthorize("@ss.hasPermi('yf:line:edit')")
    @Log(title = "股票日均线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YfStockDayLine yfStockDayLine)
    {
        return toAjax(yfStockDayLineService.updateYfStockDayLine(yfStockDayLine));
    }

    /**
     * 删除股票日均线
     */
    @PreAuthorize("@ss.hasPermi('yf:line:remove')")
    @Log(title = "股票日均线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yfStockDayLineService.deleteYfStockDayLineByIds(ids));
    }
}
